<template>
  <div class="dashboard-editor-container">
    <div class=" clearfix">
      <pan-thumb :image="avatar" style="float: left">
        Your roles:
        <span v-for="item in roles" :key="item" class="pan-info-roles">{{ item }}</span>
      </pan-thumb>
      <github-corner style="position: absolute; top: 0px; border: 0; right: 0;" />
      <div class="info-container">
        <span class="display_name">{{ name }}</span>
        <span style="font-size:20px;padding-top:20px;display:inline-block;">首页</span>
      </div>
      <el-card class="box-card">
        <div style="padding:4px 0 0;">
          <h3>欢迎来到管理系统</h3>
          <h3 class="float-right">运行时间:{{ time }}</h3>
        </div>
      </el-card>
    </div>
    <div>
      <img :src="emptyGif" class="emptyGif">
    </div>
  </div>

</template>

<script>
import { mapGetters } from 'vuex'
import PanThumb from '@/components/PanThumb'
import GithubCorner from '@/components/GithubCorner'
import {L2Dwidget} from 'live2d-widget'
export default {
  name: 'DashboardEditor',
  components: { PanThumb, GithubCorner },
  data() {
    return {
      time:'',
      currentDate: new Date(),
      // emptyGif: 'https://wpimg.wallstcn.com/0e03b7da-db9e-4819-ba10-9016ddfdaed3'
    }
  },
  methods:{
    runTime() {
      let timeold = new Date().getTime() - new Date("Auguest 5,2021").getTime();
      let msPerDay = 24 * 60 * 60 * 1000;
      let daysold = Math.floor(timeold / msPerDay);
      let str = "";
      let day = new Date();
      str += daysold + "天";
      str += day.getHours() + "时";
      str += day.getMinutes() + "分";
      str += day.getSeconds() + "秒";
      this.time = str;
    },
  },
  mounted() {
    this.timer = setInterval(this.runTime, 1000);
    setTimeout(function () {
      L2Dwidget.init({
        model: {
          jsonPath: 'https://unpkg.com/live2d-widget-model-shizuku@1.0.5/assets/shizuku.model.json',
        }
      });
    },1000);
  },
  computed: {
    ...mapGetters([
      'name',
      'avatar',
      'roles'
    ])
  }
}
</script>

<style lang="scss" scoped>
  .emptyGif {
    display: block;
    width: 45%;
    margin: 0 auto;
  }

  .dashboard-editor-container {
    background-color: #e3e3e3;
    min-height: 100vh;
    padding: 50px 60px 0px;
    .pan-info-roles {
      font-size: 12px;
      font-weight: 700;
      color: #333;
      display: block;
    }
    .info-container {
      position: relative;
      margin-left: 190px;
      height: 150px;
      line-height: 200px;
      .display_name {
        font-size: 48px;
        line-height: 48px;
        color: #212121;
        position: absolute;
        top: 25px;
      }
    }
    .box-card{
      text-align: center;
      width: 600px;
      height: 150px;
      border-radius: 30px;
      box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
      font-family: 华文楷体;
      align-items: center;
      margin: auto;
    }
    .img-card{
      width: 700px;
      margin: 20px 20px 20px 20px;
    }
    .image {
      width: 100%;
      display: block;
    }
    .img{
      width: 100%;
      align-items: center;
      height: 100%;
    }
  }
</style>
